from django.shortcuts import render
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy
from .models import Grade

class GradeListView(ListView):
    model = Grade
    template_name = 'grades/grade_list.html'
    context_object_name = 'grades'

class GradeDetailView(DetailView):
    model = Grade
    template_name = 'grades/grade_detail.html'
    context_object_name = 'grade'

class GradeCreateView(CreateView):
    model = Grade
    template_name = 'grades/grade_form.html'
    fields = ['name', 'description']
    success_url = reverse_lazy('grades:grade_list')

class GradeUpdateView(UpdateView):
    model = Grade
    template_name = 'grades/grade_form.html'
    fields = ['name', 'description']
    success_url = reverse_lazy('grades:grade_list')

class GradeDeleteView(DeleteView):
    model = Grade
    template_name = 'grades/grade_confirm_delete.html'
    success_url = reverse_lazy('grades:grade_list')